/***************************************************************
 * Name:      EventRelayDll.h
 * Purpose:   Code for SketchUp Ruby Extension EventRelay
 * Author:    pecan Heber
 * Created:   2008/10/21
 * Copyright: pecan Heber
 * License:   GPL
 **************************************************************/
/*
	This file is part of Eventrelay, a Ruby extension for SketchUp
	Copyright (C) 2008,2009 Pecan Heber

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#include "wx/wx.h"
#include "wx/evtloop.h"

#include "windows.h"

class RubyClassHandler;

#ifdef DLLFUNCTIONS_EXPORTS
    #define DLLFUNCTIONS_API __declspec(dllexport)
#else
    #define DLLFUNCTIONS_API __declspec(dllimport)
#endif

// ----------------------------------------------------------------------------
class EventRelayApp : public wxApp
// ----------------------------------------------------------------------------
{
    public:
        EventRelayApp();
        ~EventRelayApp();

        UINT PostWxEvent( const UINT Message, const WPARAM wParam, const LPARAM lParam);
        bool DllProcessAttach();
        bool OnMenuSelected( const UINT message, const WPARAM wParam, const LPARAM lParam);
        //-bool OnKeyUpDown(const UINT message, const WPARAM wParam, const LPARAM lParam );
        bool OnMouseUpDown(const UINT message, const WPARAM wParam, const LPARAM lParam );

        static RubyClassHandler* pRubyClassHandler;

        UINT m_MouseEventType;
        enum{
            m_typeRMouseDown = 1,
            m_typeLMouseDown,
            m_typeMMouseDown,
            m_typeRMouseUp,
            m_typeLMouseUp,
            m_typeMMouseUp
        };
        // Taken from SketchUp testing
        enum {
            CONSTRAIN_MODIFIER_KEY  =  16,  //0x10
            CONSTRAIN_MODIFIER_MASK =  4,   //0x04 b 0000 0100
            COPY_MODIFIER_KEY       =  17,  //0x11
            COPY_MODIFIER_MASK      =  8,   //0x08 b 0000 1000
            ALT_MODIFIER_KEY        =  18,  //0x12
            ALT_MODIFIER_MASK       =  32,  //0x20 b 0020 0000

            SHIFT_MODIFIER_MASK = CONSTRAIN_MODIFIER_MASK,
            CTRL_MODIFIER_MASK = COPY_MODIFIER_MASK
        };

    private:

        bool OnInit();
        wxWindow* CreateHiddenFrame();
        bool SubClassMainWindow(LPVOID);
        static BOOL CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam);
        static BOOL CALLBACK EnumChildWindowsProc( HWND hWnd, LPARAM lParam);
        UINT VirtualKeyToScanCode(UINT virtualKey);
        UINT ScanCodeToVirtualKey(UINT scanCode);
        RubyClassHandler* GetRubyClassHandler(){return pRubyClassHandler;}
        wxString GetMSWndMenuLabel(const unsigned menuId);
        bool CreateDebuggingLog();

        void OnButton(wxCommandEvent& evt); //*Testing* routine
        wxString m_charMouseEventType;

        DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
